package frame.system.to;

import frame.base.BaseTo;
import org.hibernate.validator.constraints.Length;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 
 * @author Administrator
 * @since
 */
@Table(name = "sys_user")
public class User extends BaseTo<Integer> {
    public static final String PASSWORD = "123456";
    public static final Integer LOCKED = 1;
    public static final Integer UNLOCK = 0;
    @Id
    @GeneratedValue(generator = "JDBC")
    private Integer id;
    /** 姓名*/
    @NotNull(message = "用户姓名不能为空")
    @Length(min = 2,max = 5,message = "用户姓名应介于2-5个字")
    private String fullName;
    /** 姓名*/
    @NotNull(message = "用户昵称不能为空")
    @Length(min = 2,max = 10,message = "用户姓名应介于2-10个字")
    private String nikeName;
    /** 账号*/
    private String username;
    /** 密码*/
    private String password;
    /**  盐*/
    private String salt;
    /** 会话ID*/
    private String sessionId;
    /** host地址*/
    private String host;
    
    /** 登录次数*/
    private Integer loginTimes;
    /** 密码错误次数*/
    private Integer errorTimes;
    /** 密码连续错误次数*/
    private Integer errorContinues;
    /** 所属部门 默认1 */
    private Integer deptId;
    /** 锁定 1锁定 0未锁定*/
    private Integer locked;
    /** 锁定原因*/
    private String lockReason;

    // 所有关联的角色
    @Transient
    private List<Role> roles;
    // 所属部门
    @Transient
    private Dept dept;
    // 默认首页URL
    @Transient
    private String baseboardUrl;

    
    public User() {
	}
	public User(Integer id) {
		this.id = id;
	}

	public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getNikeName() {
        return nikeName;
    }

    public void setNikeName(String nikeName) {
        this.nikeName = nikeName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }
    public String getSessionId() {
		return sessionId;
	}
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	
	public String getHost() {
		return host;
	}
	public void setHost(String host) {
		this.host = host;
	}
	public Integer getErrorTimes() {
        return errorTimes;
    }

    public User setErrorTimes(Integer errorTimes) {
        this.errorTimes = errorTimes;
        return this;
    }

    public Integer getErrorContinues() {
        return errorContinues;
    }

    public User setErrorContinues(Integer errorContinues) {
        this.errorContinues = errorContinues;
        return this;
    }

    public Integer getLocked() {
        return locked;
    }

    public User setLocked(Integer locked) {
        this.locked = locked;
        return this;
    }

    public String getLockReason() {
        return lockReason;
    }

    public User setLockReason(String lockReason) {
        this.lockReason = lockReason;
        return this;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public User setDeptId(Integer deptId) {
        this.deptId = deptId;
        return this;
    }

    public User setSalt(String salt) {
        this.salt = salt;
        return this;
    }

    public Integer getLoginTimes() {
        return loginTimes;
    }

    public void setLoginTimes(Integer loginTimes) {
        this.loginTimes = loginTimes;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public User setRoles(List<Role> roles) {
        this.roles = roles;
        return this;
    }

    public Dept getDept() {
        return dept;
    }

    public User setDept(Dept dept) {
        this.dept = dept;
        return this;
    }

    public String getBaseboardUrl() {
        return baseboardUrl;
    }

    public User setBaseboardUrl(String baseboardUrl) {
        this.baseboardUrl = baseboardUrl;
        return this;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", fullName='" + fullName + '\'' +
                ", nikeName='" + nikeName + '\'' +
                ", username='" + username + '\'' +
                ", loginTimes=" + loginTimes +
                '}';
    }
}
